<template>
	<view>
		<newNavBar></newNavBar>
		<view style="padding-left: 10px;  margin: 10px; background-color: #fff; border-radius: 6px;">
			<view class="flex-between">
				<view style="display: flex; flex-direction: row; align-items: center;">
					<!-- <view class="flexRight-icon" :style="{'width':'25px','height':'25px','background-image': 'linear-gradient(#9f47f6, #8940f6)' }">
						<uni-icons type="scan" :size="20" color="#ffffff"></uni-icons>
					</view> -->
					<text>是否开启连续扫描</text>
				</view>
				<view style="display: flex; flex-direction: row; align-items: center;">
					<switch :color="mainColor" :checked="isContinuScan" @change="scanChange" style="transform:scale(0.9)"></switch>
				</view>
			</view>

		</view>
		<view style="padding-left: 10px;  margin: 10px; background-color: #fff; border-radius: 6px;">

			<view class="flex-between" @click="systemInfo('csy')">
				<view style="display: flex; flex-direction: row; align-items: center;">
					<!-- <view class="flexRight-icon" :style="{'background-image': 'linear-gradient(#3851f6, #3851f6)' }">
						<uni-icons customPrefix="my-iconfont" type="icon-quanjushezhi" :size="18" color="#ffffff" />
					</view> -->
					<text>软件更新</text>
				</view>
				<view style="display: flex; flex-direction: row; align-items: center;">
					<uni-icons type="right" size="16px"></uni-icons>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import * as SystemJs from '@/common/system.js'
	import * as configJs from '@/common/config.js'
	export default {
		data() {
			return {
				mainColor: '',
				isContinuScan: false, //是否开启连续扫描功能
				versionName: ''
			}
		},
		onShow() {
			this.mainColor = configJs.baseColor.mainTitleColor;
			var info = "";
			uni.getSystemInfo({
				success: (res) => {
					// this.$refs.alertDialog.open()
					this.versionName = res.appVersion
				}
			})

			// #ifdef APP-PLUS
			SystemJs.baseInfo.getDeviceInfo()
			plus.runtime.getProperty(plus.runtime.appid, (inf) => {
				this.versionName = inf.version
			})
			// #endif
		},
		onLoad() {
			SystemJs.systemJs.showTitleBar('系统和更新', true);
			var scan = uni.getStorageSync('isContinuScan');
			if (scan) {
				this.isContinuScan = Boolean(scan);
			}
		},
		methods: {
			/**
			 * 是否开启连续扫描改变事件
			 * @param {Object} e
			 */
			scanChange(e) {
				var detail = e.detail;
				uni.setStorageSync('isContinuScan', detail.value)
			},
			systemInfo(type) {
				var url;
				if (!SystemJs.systemJs.IsEmpty(type)) {
					switch (type) {
						case "csy":
							url = '/pages/main/checkSystemInfo?versionName=' + this.versionName;
							break;
						case "upa":
							url = '/pages/main/UpdatePassword';
							break;
						case "wage":
							url = '/pages/business/productWage/ProductWageInfo?pageCode=wageinfo&pageName=绩效查询'
							break;
					}
					uni.navigateTo({
						url: url
					})
				}
			}
		}
	}
</script>

<style>
	.flex-between {
		display: flex;
		justify-content: space-between;
		align-content: center;
		padding-top: 15px;
		padding-bottom: 15px;
		padding-right: 10px;
	}

	.flexRight-icon {
		margin-right: 10px;
		padding-bottom: 0px;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50%;
		width: 20px;
		height: 20px;
	}
</style>